package com.xlt.activiti.one;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

public class ActivitiStartInstance {

    // 前提是完成部署工作
    public static void startInstance() {
        // 1.得到processEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 2.得到RunService 对象
        RuntimeService runtimeService = processEngine.getRuntimeService();
        // 3.创建流程实例
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday");

        // 4.输出实例相关信息
        System.out.println("流程部署ID" + processInstance.getDeploymentId());
        System.out.println("流程实例ID" + processInstance.getId());
        System.out.println("活动ID" + processInstance.getActivityId());
    }
}
